<html>

	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/json.js"></script>

	<button onclick="post();" >Teste</button>
	<button onclick="postArray();" >TesteArray</button>
	<button onclick="postArrayInt();" >TesteArrayInt</button>
	<button onclick="postArrayComplex();" >TesteComplex</button>

	<script>

		function post()
		{
			//$.jproxy.init();
			//$.jproxy.bind('PublisherFacade', 'br.com.uol.monaco.publisher.PublisherFacade');
			//$('PublisherFacade.saveMedia()').jproxy(json, cb);

			var json =
			{
				method :	'test',
				args:		undefined
			};
			send(json, postCallback);
		}

		function postCallback(response, status)
		{
			alert('response: ' + response + ' status: ' + status);
		}

		function postArray()
		{
			var json =
			{
				method :	'hello',
				args:		['teste', 'rod', 'zac']
			};
			send(json, postArrayCallback);
		}

		function postArrayCallback(response, status)
		{
			alert('status: ' + status);
		}

		function postArrayInt()
		{
			var json =
			{
				method :	'hello',
				args:		[1, 2, 3]
			};
			send(json, postArrayIntCallback);
		}

		function postArrayIntCallback(response, status)
		{
			alert('status: ' + status);
		}

		function postArrayComplex()
		{
			var json =
			{
				method :	'hello',
				args:		{name: 'rod', lastNames: ['constantin', 'ctenas', 'zaccara']}
			};
			send(json,  postArrayComplexCallback);
		}

		function postArrayComplexCallback(response, status)
		{
			alert('status:' + status);
		}

		function send(json, callback)
		{
			$.ajax
			(
				{
					type: 'POST',
					url: 'http://localhost:8080/jproxy-sample/jproxy/TestFacade',
					data: 'json=' + JSON.encode(json),
					dataType: 'json',
					success: callback,
					error: function()
					{
						alert('Erro');
					}
				}
			);
		}

	</script>

</html>